#!/bin/sh

# The runOK function does the following for a test file that is not expected
# to cause any parser errors:

# 1. It prints the name of the test file.

# 2. It runs the test file through the dmisConformanceTester using
# level 3 of prismatic and all seven addenda and redirects the output
# to the file "junk1". The junk1 file will contain message lines that
# report any errors or warnings and the numbers of errors and warnings.
# If there are no errors or warnings, the junk1 file will be:
#     0 parser errors
#     0 parser warnings
#
#     0 conformance checker errors

# 3. check4Lines checks that 1, 2, or all 4 lines shown above are present
# in junk1, according to whether the first argument to runOK is 1, 2, or
# 4. If the check fails, runOK prints "message test failed" and returns 1.

INA=../../parserTestFiles/annexAIn
INO=../../parserTestFiles/okIn

function runOK
{
   echo $2
   ../../bin/dmisConformanceTester $2 PM3 RY3 CT3 MC3 IP3 QI3 MU3 SF3 > junk1
   ../../bin/check4Lines junk1 $1
   if  [ "$?" -ne "0" ]; then
     echo "message test failed"
     return 1
   fi
   return 0
}

# syntactically correct programs from Appendix A of DMIS 5.1
runOK 4 $INA/A.01.dmi              || exit
runOK 4 $INA/A.02.dmi              || exit
runOK 4 $INA/A.03.dmi              || exit
runOK 4 $INA/A.04.2.dmi            || exit
runOK 4 $INA/A.05.dmi              || exit
runOK 4 $INA/A.06.dmi              || exit
runOK 4 $INA/A.07.dmi              || exit
runOK 4 $INA/A.08.1.dmi            || exit
runOK 4 $INA/A.08.2.dmi            || exit
runOK 2 $INA/A.08.3.dmi            || exit
runOK 4 $INA/A.09.dmi              || exit
runOK 4 $INA/A.10.dmi              || exit
runOK 4 $INA/A.11.dmi              || exit
runOK 4 $INA/A.12.dmi              || exit
runOK 4 $INA/A.13.dmi              || exit
runOK 4 $INA/A.14.dmi              || exit
runOK 2 $INA/A.15.dmi              || exit
runOK 4 $INA/A.16.dmi              || exit
runOK 2 $INA/A.17.dmi              || exit
runOK 4 $INA/A.18.dmi              || exit
runOK 4 $INA/A.19.1.dmi            || exit
runOK 4 $INA/A.19.2.dmi            || exit
runOK 4 $INA/A.20.dmi              || exit
runOK 4 $INA/A.21.dmi              || exit
runOK 4 $INA/A.22.1.dmi            || exit
runOK 4 $INA/A.22.2.dmi            || exit
runOK 2 $INA/A.23.dmi              || exit
runOK 4 $INA/A.24.dmi              || exit
runOK 4 $INA/A.25.1.dmi            || exit
runOK 4 $INA/A.25.2.dmi            || exit
runOK 4 $INA/A.25.3.dmi            || exit
runOK 4 $INA/A.26.dmi              || exit
runOK 4 $INA/A.27.dmi              || exit
runOK 1 $INA/A.28.dmi              || exit
runOK 4 $INA/A.29.dmi              || exit
runOK 2 $INA/A.30.1.dmi            || exit
runOK 4 $INA/A.30.2.dmi            || exit
runOK 4 $INA/A.30.3.dmi            || exit
runOK 4 $INA/A.30.4.dmi            || exit
runOK 2 $INA/A.30.5.dmi            || exit
runOK 2 $INA/A.30.6.dmi            || exit
runOK 4 $INA/A.30.7.dmi            || exit
runOK 2 $INA/A.31.dmi              || exit
runOK 4 $INA/A.32.dmi              || exit
runOK 4 $INA/A.33.dmi              || exit
runOK 4 $INA/A.34.1.dmi            || exit
runOK 4 $INA/A.34.2.dmi            || exit
runOK 4 $INA/A.34.3.dmi            || exit
runOK 4 $INA/A.35.dmi              || exit
runOK 4 $INA/A.36.dmi              || exit
runOK 4 $INA/A.37.dmi              || exit
runOK 4 $INA/A.38.dmi              || exit

# syntactically correct programs testing specific DMIS commands
runOK 4 $INO/aclrat1.dmi           || exit
runOK 2 $INO/algdef1.dmi           || exit
runOK 4 $INO/assign1.dmi           || exit
runOK 4 $INO/badtst1.dmi           || exit
runOK 4 $INO/bound1.dmi            || exit
runOK 4 $INO/calib1.dmi            || exit
runOK 4 $INO/call1.dmi             || exit
runOK 4 $INO/case1.dmi             || exit
runOK 4 $INO/clmpid1.dmi           || exit
runOK 4 $INO/clmpid2.dmi           || exit
runOK 4 $INO/clmpsn1.dmi           || exit
runOK 4 $INO/close1.dmi            || exit
runOK 2 $INO/cmpntgrp1.dmi         || exit
runOK 4 $INO/cnfrmrul1.dmi         || exit
runOK 2 $INO/const1.dmi            || exit
runOK 4 $INO/const2.dmi            || exit
runOK 4 $INO/const3.dmi            || exit
runOK 4 $INO/const4.dmi            || exit
runOK 4 $INO/const5.dmi            || exit
runOK 4 $INO/const6.dmi            || exit
runOK 4 $INO/const7.dmi            || exit
runOK 4 $INO/const8.dmi            || exit
runOK 4 $INO/const9.dmi            || exit
runOK 4 $INO/const10.dmi           || exit
runOK 4 $INO/const11.dmi           || exit
runOK 4 $INO/const12.dmi           || exit
runOK 2 $INO/const13.dmi           || exit
runOK 4 $INO/const14.dmi           || exit
runOK 2 $INO/const15.dmi           || exit
runOK 4 $INO/crgdef1.dmi           || exit
runOK 2 $INO/crmode1.dmi           || exit
runOK 2 $INO/croscl1.dmi           || exit
runOK 4 $INO/crslct1.dmi           || exit
runOK 4 $INO/cutcom1.dmi           || exit
runOK 4 $INO/czone1.dmi            || exit
runOK 4 $INO/czslct1.dmi           || exit
runOK 4 $INO/datdef1.dmi           || exit
runOK 4 $INO/datset1.dmi           || exit
runOK 4 $INO/dattrgdef1.dmi        || exit
runOK 4 $INO/decl1.dmi             || exit
runOK 2 $INO/decpl1.dmi            || exit
runOK 2 $INO/delete1.dmi           || exit
runOK 4 $INO/device1.dmi           || exit
runOK 4 $INO/dftcas1.dmi           || exit
runOK 4 $INO/disply1.dmi           || exit
runOK 2 $INO/dmehw1.dmi            || exit
runOK 4 $INO/dmeid1.dmi            || exit
runOK 2 $INO/dmesw1.dmi            || exit
runOK 4 $INO/dmeswi1.dmi           || exit
runOK 4 $INO/dmeswv1.dmi           || exit
runOK 2 $INO/dmis1.dmi             || exit
runOK 4 $INO/dmismd1.dmi           || exit
runOK 4 $INO/dmismn1.dmi           || exit
runOK 4 $INO/do1.dmi               || exit
runOK 4 $INO/else1.dmi             || exit
runOK 4 $INO/endcas1.dmi           || exit
runOK 4 $INO/enddo1.dmi            || exit
runOK 4 $INO/endfil1.dmi           || exit
runOK 4 $INO/endgo1.dmi            || exit
runOK 4 $INO/endif1.dmi            || exit
runOK 4 $INO/endmac1.dmi           || exit
runOK 4 $INO/endmes1.dmi           || exit
runOK 4 $INO/endsel1.dmi           || exit
runOK 4 $INO/endsimreqt1.dmi       || exit
runOK 4 $INO/endxtn1.dmi           || exit
runOK 4 $INO/equate1.dmi           || exit
runOK 4 $INO/error1.dmi            || exit
runOK 4 $INO/eval1.dmi             || exit
runOK 4 $INO/extens1.dmi           || exit
runOK 4 $INO/extfil1.dmi           || exit
runOK 4 $INO/featArc1.dmi          || exit
runOK 4 $INO/featArc2.dmi          || exit
runOK 4 $INO/featCircle1.dmi       || exit
runOK 4 $INO/featCompound1.dmi     || exit
runOK 4 $INO/featCone1.dmi         || exit
runOK 4 $INO/featConradsegmnt1.dmi || exit
runOK 4 $INO/featCparln1.dmi       || exit
runOK 4 $INO/featCylndr1.dmi       || exit
runOK 4 $INO/featCylradsegmnt1.dmi || exit
runOK 2 $INO/featEdgept1.dmi       || exit
runOK 4 $INO/featEllips1.dmi       || exit
runOK 4 $INO/featElongcyl1.dmi     || exit
runOK 4 $INO/featGcurve1.dmi       || exit
runOK 2 $INO/featGeom1.dmi         || exit
runOK 4 $INO/featGsurf1.dmi        || exit
runOK 4 $INO/featLine1.dmi         || exit
runOK 2 $INO/featObject1.dmi       || exit
runOK 4 $INO/featParpln1.dmi       || exit
runOK 4 $INO/featPatern1.dmi       || exit
runOK 4 $INO/featPlane1.dmi        || exit
runOK 4 $INO/featPoint1.dmi        || exit
runOK 4 $INO/featRctngl1.dmi       || exit
runOK 4 $INO/featRevsurf1.dmi      || exit
runOK 4 $INO/featSphere1.dmi       || exit
runOK 4 $INO/featSphradsegmnt1.dmi || exit
runOK 4 $INO/featSympln1.dmi       || exit
runOK 4 $INO/featTorradsegmnt1.dmi || exit
runOK 4 $INO/featTorus1.dmi        || exit
runOK 2 $INO/fedrat1.dmi           || exit
runOK 2 $INO/fildef1.dmi           || exit
runOK 4 $INO/filnam1.dmi           || exit
runOK 4 $INO/finpos1.dmi           || exit
runOK 4 $INO/fixtid1.dmi           || exit
runOK 4 $INO/fixtsn1.dmi           || exit
runOK 4 $INO/fly1.dmi              || exit
runOK 4 $INO/from1.dmi             || exit
runOK 2 $INO/geoalg1.dmi           || exit
runOK 2 $INO/geoalg2.dmi           || exit
runOK 2 $INO/geom1.dmi             || exit
runOK 4 $INO/gohome1.dmi           || exit
runOK 4 $INO/gotarg1.dmi           || exit
runOK 4 $INO/goto1.dmi             || exit
runOK 2 $INO/group1.dmi            || exit
runOK 4 $INO/if1.dmi               || exit
runOK 2 $INO/includ1.dmi           || exit
runOK 4 $INO/iterat1.dmi           || exit
runOK 4 $INO/jumpto1.dmi           || exit
runOK 4 $INO/keychar1.dmi          || exit
runOK 2 $INO/litdef1.dmi           || exit
runOK 2 $INO/litdef2.dmi           || exit
runOK 4 $INO/locate1.dmi           || exit
runOK 4 $INO/lotid1.dmi            || exit
runOK 4 $INO/macro1.dmi            || exit
runOK 4 $INO/macro2.dmi            || exit
runOK 4 $INO/macro3.dmi            || exit
runOK 4 $INO/macro4.dmi            || exit
runOK 4 $INO/macro5.dmi            || exit
runOK 2 $INO/matdef1.dmi           || exit
runOK 2 $INO/meas1.dmi             || exit
runOK 2 $INO/meas2.dmi             || exit
runOK 4 $INO/mfgdev1.dmi           || exit
runOK 4 $INO/mode1.dmi             || exit
runOK 2 $INO/obtain1.dmi           || exit
runOK 4 $INO/obtainCT.dmi          || exit
runOK 4 $INO/obtainIP.dmi          || exit
runOK 4 $INO/obtainMC.dmi          || exit
runOK 4 $INO/obtainQI.dmi          || exit
runOK 4 $INO/obtainRY.dmi          || exit
runOK 4 $INO/open1.dmi             || exit
runOK 4 $INO/operid1.dmi           || exit
runOK 2 $INO/output1.dmi           || exit
runOK 2 $INO/pameas1.dmi           || exit
runOK 4 $INO/partid1.dmi           || exit
runOK 4 $INO/partrv1.dmi           || exit
runOK 4 $INO/partsn1.dmi           || exit
runOK 2 $INO/path1.dmi             || exit
runOK 4 $INO/planid1.dmi           || exit
runOK 4 $INO/pop1.dmi              || exit
runOK 4 $INO/prcomp1.dmi           || exit
runOK 4 $INO/prevop1.dmi           || exit
runOK 4 $INO/procid1.dmi           || exit
runOK 4 $INO/prompt1.dmi           || exit
runOK 4 $INO/psthru1.dmi           || exit
runOK 4 $INO/ptbuff1.dmi           || exit
runOK 4 $INO/ptmeas1.dmi           || exit
runOK 4 $INO/push1.dmi             || exit
runOK 4 $INO/qisdef1.dmi           || exit
runOK 2 $INO/rapid1.dmi            || exit
runOK 4 $INO/read1.dmi             || exit
runOK 2 $INO/recall1.dmi           || exit
runOK 2 $INO/refmnt1.dmi           || exit
runOK 2 $INO/report1.dmi           || exit
runOK 4 $INO/resume1.dmi           || exit
runOK 2 $INO/rmeas1.dmi            || exit
runOK 4 $INO/rmeas2.dmi            || exit
runOK 4 $INO/rmeas3.dmi            || exit
runOK 4 $INO/rmeas4.dmi            || exit
runOK 4 $INO/rmeas5.dmi            || exit
runOK 4 $INO/rmeas6.dmi            || exit
runOK 2 $INO/rmeas7.dmi            || exit
runOK 4 $INO/rotab1.dmi            || exit
runOK 4 $INO/rotate1.dmi           || exit
runOK 4 $INO/rotdef1.dmi           || exit
runOK 4 $INO/rotset1.dmi           || exit
runOK 2 $INO/save1.dmi             || exit
runOK 4 $INO/scnmod1.dmi           || exit
runOK 2 $INO/scnset1.dmi           || exit
runOK 2 $INO/scnset2.dmi           || exit
runOK 4 $INO/select1.dmi           || exit
runOK 2 $INO/sensor1.dmi           || exit
runOK 4 $INO/simreqt1.dmi          || exit
runOK 4 $INO/snsdef1.dmi           || exit
runOK 2 $INO/snsdef2.dmi           || exit
runOK 2 $INO/snsdef3.dmi           || exit
runOK 2 $INO/snsdef4.dmi           || exit
runOK 2 $INO/snsdef5.dmi           || exit
runOK 2 $INO/snsdef6.dmi           || exit
runOK 2 $INO/snset1.dmi            || exit
runOK 2 $INO/snsgrp1.dmi           || exit
runOK 2 $INO/snslct1.dmi           || exit
runOK 4 $INO/snsmnt1.dmi           || exit
runOK 4 $INO/tecomp1.dmi           || exit
runOK 4 $INO/text1.dmi             || exit
runOK 2 $INO/thldef1.dmi           || exit
runOK 4 $INO/tolAngl1.dmi          || exit
runOK 4 $INO/tolAnglB1.dmi         || exit
runOK 4 $INO/tolAnglR1.dmi         || exit
runOK 4 $INO/tolAnglWrt1.dmi       || exit
runOK 4 $INO/tolCirlty1.dmi        || exit
runOK 4 $INO/tolCompos1.dmi        || exit
runOK 4 $INO/tolConcen1.dmi        || exit
runOK 4 $INO/tolCortol1.dmi        || exit
runOK 4 $INO/tolCprofl1.dmi        || exit
runOK 4 $INO/tolCprofs1.dmi        || exit
runOK 4 $INO/tolCrnout1.dmi        || exit
runOK 4 $INO/tolCylcty1.dmi        || exit
runOK 4 $INO/tolDiam1.dmi          || exit
runOK 4 $INO/tolDistB1.dmi         || exit
runOK 4 $INO/tolDistWrt1.dmi       || exit
runOK 4 $INO/tolFlat1.dmi          || exit
runOK 4 $INO/tolGtol1.dmi          || exit
runOK 4 $INO/tolParlel1.dmi        || exit
runOK 4 $INO/tolPerp1.dmi          || exit
runOK 4 $INO/tolPos1.dmi           || exit
runOK 4 $INO/tolProfl1.dmi         || exit
runOK 4 $INO/tolProfp1.dmi         || exit
runOK 4 $INO/tolProfs1.dmi         || exit
runOK 4 $INO/tolRad1.dmi           || exit
runOK 4 $INO/tolStrght1.dmi        || exit
runOK 4 $INO/tolSym1.dmi           || exit
runOK 4 $INO/tolTrnout1.dmi        || exit
runOK 2 $INO/tolUsetol1.dmi        || exit
runOK 4 $INO/tolWidth1.dmi         || exit
runOK 4 $INO/tooldf1.dmi           || exit
runOK 4 $INO/trans1.dmi            || exit
runOK 4 $INO/uncertalg1.dmi        || exit
runOK 4 $INO/uncertset1.dmi        || exit
runOK 4 $INO/units1.dmi            || exit
runOK 2 $INO/value1.dmi            || exit
runOK 2 $INO/value2.dmi            || exit
runOK 2 $INO/value3.dmi            || exit
runOK 2 $INO/value4.dmi            || exit
runOK 2 $INO/value5.dmi            || exit
runOK 2 $INO/vform1.dmi            || exit
runOK 2 $INO/windef1.dmi           || exit
runOK 2 $INO/windef2.dmi           || exit
runOK 4 $INO/wkplan1.dmi           || exit
runOK 2 $INO/wrist1.dmi            || exit
runOK 4 $INO/write1.dmi            || exit
runOK 4 $INO/xtern1.dmi            || exit
runOK 4 $INO/xtract1.dmi           || exit

# syntactically correct programs testing special features
runOK 1 $INO/confusing.dmi         || exit
runOK 4 $INO/exprsArith.dmi        || exit
runOK 4 $INO/exprsLogic.dmi        || exit
runOK 4 $INO/exprsVector.dmi       || exit
runOK 4 $INO/funcsBool.dmi         || exit
runOK 4 $INO/funcsChar.dmi         || exit
runOK 4 $INO/funcsInt.dmi          || exit
runOK 4 $INO/funcsReal.dmi         || exit
runOK 4 $INO/funcsVec.dmi          || exit
runOK 4 $INO/preTest1.dmi          || exit
runOK 4 $INO/preTest2.dmi          || exit
runOK 4 $INO/preTest3.dmi          || exit
runOK 4 $INO/preTest4.dmi          || exit

rm junk1
